<!-- 选择球员 -->
<template>
	<view class="choose-payer page-background">
		<view @click="choosePlayer(index)" v-for="(item,index) in appointPlayerData.list" :key="index" :class="appointPlayerData.checkedIndex==index?'player-item item-box checked':'player-item item-box'">
			<view class="item-top">
				<view class="left">
					<image v-if="item.playerIcon" class="icon" :src="item.playerIcon" mode=""></image>
          <template v-else>
            <image v-if="item.sex==2" class="icon" :src="'@/static/images/mine/player-icon-gril-grey.png'|addBaseImgUrl" mode="">
            </image>
            <image v-else class="icon" :src="'@/static/images/mine/player-icon-boy-grey.png'|addBaseImgUrl" mode=""></image>
          </template>
					<image v-if="item.sex=='1'" class="icon-sex" :src="'@/static/images/mine/icon-sex-boy.png'|addBaseImgUrl" mode=""></image>
					<image v-else class="icon-sex"  :src="'@/static/images/mine/icon-sex-gril.png'|addBaseImgUrl" mode=""></image>
				</view>
				<view class="right">
					<view class="title-row flex-box">
						<text class="player-name">{{item.relName}}</text>
						<view class="player-tag yellow">
							{{item.typeValue}}
						</view>
						<view class="player-tag orange">
							{{'级别L'+''}}
						</view>
					</view>
					<view class="content-row">
						手机：{{item.emergencyContact||''}}
					</view>
					<view class="content-row">
						出生日期：{{item.birthday}}
					</view>
				</view>
				<!-- <view class="change-player">
					<text>切换球员</text>
					<van-icon name="arrow" size="12px" color="#999999" />
				</view> -->
			</view>
			<view class="item-bottom">
				<image class="icon-image" :src="'@/static/images/icon-calendar.png'|addBaseImgUrl" mode=""></image>
				<view class="course-record">
					<view class="record-item">
						<view v-if="['0','1'].includes(item.classType)" class="record-left">
							<text>{{`${item.useCount}/${item.hourType==1?'不限':item.totalCount}课时`}}</text>
							<text v-if="item.endDate">{{`有效期至${item.endDate.substr(0,10)}`}}</text>
						</view>
						<view v-else-if="item.classStart&&item.classEnd" class="record-left">
							<text>{{`${item.classStart.substr(0,10)}-${item.classEnd.substr(0,10)}`}}</text>
						</view>
						<view class="record-right">
							{{item.classStateStr}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState, mapGetters, mapMutations } from 'vuex'
	export default {
		data() {
			return {
				
			};
        },
        onLoad(data) {
			
        },
		computed: {
			...mapState(['userInfo','accessToken','appointPlayerData'])
		},
        methods:{
			choosePlayer(index){
				this.appointPlayerData.checkedIndex = index
				let timer = setTimeout(()=>{
					clearTimeout(timer)
					uni.navigateBack({
						delta:1
					})
				},300)
			}
        }
	}
</script>

<style scoped lang="scss">
	.choose-payer{
		overflow: hidden;
		min-height: 100vh;
		padding-bottom: 20rpx;
		.player-item{
			padding: 0 20rpx;
			&.checked{
				border: 2rpx solid #2E87FF;
			}
			.item-top{
				padding: 30rpx 0;
				display: flex;
				align-items: flex-start;
				justify-content: flex-start;
				position: relative;
				.left{
					width: 110rpx;
					height: 110rpx;
					position: relative;
					margin-right: 20rpx;
					background-color: #F2F2F2;
					border-radius: 50%;
					image{
						width: 100%;
						height: 100%;
						vertical-align: middle;
					}
					.icon{
						border-radius: 50%;
					}
					.icon-sex{
						position: absolute;
						right: 0;
						top: 0;
						width: 30rpx;
						height: 30rpx;
					}
				}
				.right{
					.title-row{
						justify-content: flex-start;
						align-items: center;
						.player-name{
							font-size: 34rpx;
							margin-right: 10rpx;
						}
						.player-tag{
							font-size: 22rpx;
							height: 32rpx;
							line-height: 32rpx;
							-webkit-border-radius: 5rpx;
							border-radius: 5rpx;
							text-align: center;
							margin-right: 10rpx;
							padding: 0 10rpx;
							&.yellow{
								border: 2rpx solid #FFE1A2;
								color: $bg-color-yellow1;
							}
							&.orange{
								border: 2rpx solid #FFC8C3;
								color: #E14806;
							}
						}
					}
					.content-row{
						font-size: 26rpx;
						color: $text-color-grey;
						margin-top: 5rpx;
					}
				}
				.change-player{
					position: absolute;
					right: 0;
					top: 50%;
					display: flex;
					justify-content: space-between;
					height: 70rpx;
					margin-top: -35rpx;
					align-items: center;
					text{
						margin-right: 15rpx;
						font-size: 26rpx;
						color: #333;
					}
				}
			}
			.item-bottom{
				padding: 20rpx 0;
				border-top: 2rpx solid #E9E9E9;
				position: relative;
				.icon-image{
					width: 48rpx;
					height: 48rpx;
					position: absolute;
					top: 20rpx;
					left: 30rpx;
				}
				.course-record{
					padding: 0 10rpx 0 130rpx;
					.record-item{
						display: flex;
						justify-content: space-between;
						align-items: center;
						&+.record-item{
							margin-top: 10rpx;
						}
						view{
							font-size: 26rpx;
							color: #999999;
						}
						.record-left{
							text{
								margin-right: 20rpx;
							}
						}
					}
				}
			}
		}
	}
</style>
